<template>
	<view class="page" :style="themeColor">
		<view class="flex flex-direction flex-wrap align-stretch benben-position-layout flex myNew_flex_0"
			:style="{height:(88+StatusBarRpx)+'rpx',paddingTop:StatusBarRpx+'rpx'}">
			<view class='flex flex-wrap align-center justify-between myNew_fd0_0'>
				<view class='flex flex-wrap align-center myNew_fd0_0_c0' @tap.stop="handleJumpDiy" data-type="back"
					data-url="1">
					<text class='fu-iconfont2  myNew_fd0_0_c0_c0'>&#xE794;</text>
				</view>
				<view class='flex flex-wrap align-center'>
					<text class='myNew_fd0_0_c1_c0'>我的消息</text>
				</view>
				<view class='flex align-center justify-end myNew_fd0_0_c2'>
				</view>
			</view>

		</view>
		<view :style="{height: (88+StatusBarRpx)+'rpx'}"></view>
		<!---flex布局flex布局开始-->
		<view class="flex flex-direction flex-wrap align-stretch benben-flex-layout myNew_flex_1">
			<view class='flex flex-wrap align-center' @tap.stop="jumpFunc(v.msg_type)" v-for="(v, k) in newsList"
				:key="k">
				<view class='flex align-center justify-center myNew_fd1_0_c0'>
					<image class='myNew_fd1_0_c0_c0' mode="aspectFill" :src='v.thumb'></image>
					<benben-message-num class='myNew_fd1_0_c0_c1' size='24' :message-num="v.unread_nums" color='#fff'
						background-color='red'>
					</benben-message-num>
				</view>
				<view class='flex flex-direction flex-wrap align-stretch flex-sub myNew_fd1_0_c1'>
					<view class='flex flex-wrap align-center justify-between'>
						<text class='myNew_fd1_0_c1_c0_c0'>{{v.name}}</text>
						<text class='myNew_fd1_0_c1_c0_c1'>{{v.time}}</text>
					</view>
					<text class='myNew_fd1_0_c1_c1' v-if="v.msg_content">{{v.msg_content}}</text>
					<text class='myNew_fd1_0_c1_c1' v-else>暂无消息</text>
				</view>
			</view>
			<t-slide ref="slide" @del="del" @itemClick="goClick">
				<template v-slot:default="{item}">
					<view class='flex flex-wrap align-center' style="border: 1px solid #fff !important;">
						<view class='flex align-center justify-center myNew_fd1_0_c0'>
							<image class='myNew_fd1_0_c0_c0' mode="aspectFill" :src='item.item.avatar'></image>
						</view>
						<view class='flex flex-direction flex-wrap align-stretch flex-sub myNew_fd1_0_c1'>
							<view class='flex flex-wrap align-center justify-between'>
								<text class='myNew_fd1_0_c1_c0_c0'>{{item.item.username}}</text>
								<text class='myNew_fd1_0_c1_c0_c1'>{{item.item.create_time}}</text>
							</view>
							<text class='myNew_fd1_0_c1_c1' v-if="item.item.content">
								<view v-if="item.item.msg_type == 1 || item.item.msg_type == 4">
									<u-parse :html="item.item.content"></u-parse>
								</view>
								<view v-if="item.item.msg_type == 2">
									[图片]
								</view>
							</text>
							<text class='myNew_fd1_0_c1_c1' v-else>暂无消息</text>
						</view>
					</view>
				</template>

			</t-slide>
		</view>
		<!---flex布局flex布局结束-->


	</view>
</template>
<script>
	import {
		validate
	} from '@/common/utils/validate.js'
	import tSlide from "@/components/t-slide/t-slide.nvue"
	export default {
		components: {
			tSlide
		},


		data() {
			return {
				"newsList": [],
				"kefuList": [],
			};
		},
		computed: {
			themeColor() {
				return this.$store.getters.themeColor
			},

		},
		watch: {},
		onLoad(options) {

		},
		onUnload() {

		},
		onReady() {

		},
		onShow() {
			this.NewsListFunc();
			this.getKefu();
		},
		onHide() {

		},
		onResize() {

		},
		onPullDownRefresh() {

		},
		onReachBottom(e) {

		},
		onPageScroll(e) {

		},
		methods: {
			//获取消息列表
			async NewsListFunc() {
				//请求方法
				//数据验证

				let datanewsList = await this.$api.get(global.apiUrls.post6439160c0c0a8, {

				});
				if (datanewsList.data.code != 1) {
					this.$message.info(datanewsList.data.msg);
					return
				}
				let infonewsList = datanewsList.data;
				this.newsList = infonewsList.data
			},
			// 获取客服列表
			getKefu() {
				this.$api.post(global.apiUrls.post64db43d1d67b5, {
					page: 1
				}).then(res => {
					// console.log(res);
					if (res.data.code == 1) {
						if (res.data.data.length == 0) {
							this.kefuList = [];
							this.$nextTick(() => {
								this.$refs.slide.assignment(this.kefuList);
							})
							return;
						}
						this.kefuList = res.data.data.data;
						this.$nextTick(() => {
							this.$refs.slide.assignment(this.kefuList);
						})
					} else {
						this.$message.info(res.data.msg);
					}
				})
			},
			del(e) {
				this.$api.post(global.apiUrls.post656ee317c913d, {
					// aid: e.aid
				}).then(res => {
					this.$message.info(res.data.msg);
					if (res.data.code == 1) {
						this.getKefu();
					}
				})
			},
			goClick(e) {
				uni.navigateTo({
					url: '/pages/homepage/customerChat/customerChat?id=' + e.user_id
				})
			},
			goKefu(kefu_id) {
				uni.navigateTo({
					url: '/pages/homepage/customerChat/customerChat?id=' + kefu_id
				})
			},
			//跳转
			jumpFunc(typeId) {
				if (typeId == '1') {
					this.$urouter.navigateTo(`/pages/wode/platformAnnouncement/platformAnnouncement`);
				}
				if (typeId == '2') {
					this.$urouter.navigateTo(`/pages/wode/orderNews/orderNews`);
				}
				return
			}
		}
	};
</script>
<style lang="scss" scoped>
	.page {
		width: 100vw;
		overflow-x: hidden;
		min-height: calc(100vh - var(--window-bottom));
		background: #F8F8F8;
		background-size: 100% auto !important;
	}

	.myNew_flex_0 {
		border-bottom: 1px solid #eee;
		background: #fff;
		width: 750rpx;
		height: 88rpx;
		overflow: hidden;
		z-index: 10;
		top: 0rpx;
		background-size: 100% auto !important;
	}

	.myNew_fd0_0_c2 {
		padding: 0rpx 0rpx 0rpx 0rpx;
		width: 200rpx;
	}

	.myNew_fd0_0_c1_c0 {
		font-size: 36rpx;
		font-weight: 500;
		color: #333333;
	}

	.myNew_fd0_0_c0_c0 {
		font-size: 36rpx;
		color: #333;
		font-weight: 500;
	}

	.myNew_fd0_0_c0 {
		width: 200rpx;
	}

	.myNew_fd0_0 {
		padding: 0rpx 32rpx 0rpx 32rpx;
		line-height: 88rpx;
	}

	.myNew_flex_1 {
		background: #fff;
		background-size: 100% auto !important;
		padding: 0rpx 32rpx 0rpx 32rpx;
	}

	.myNew_fd1_1_c1_c1 {
		font-size: 24rpx;
		font-weight: 400;
		color: rgba(153, 153, 153, 1);
		line-height: 33rpx;
		-webkit-line-clamp: 1;
		overflow: hidden;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-box-orient: vertical;
		margin: 17rpx 0rpx 0rpx 0rpx;
	}

	.myNew_fd1_1_c1_c0_c1 {
		font-size: 24rpx;
		font-weight: 400;
		color: rgba(191, 191, 191, 1);
		line-height: 33rpx;
		text-align: right;
		max-width: 150rpx;
		-webkit-line-clamp: 1;
		overflow: hidden;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-box-orient: vertical;
	}

	.myNew_fd1_1_c1_c0_c0 {
		font-size: 28rpx;
		font-weight: 500;
		line-height: 40rpx;
		max-width: 450rpx;
		color: #333;
		-webkit-line-clamp: 1;
		overflow: hidden;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-box-orient: vertical;
	}

	.myNew_fd1_1_c1 {
		border-bottom: 1px solid #EEEEEE;
		padding: 32rpx 0rpx 32rpx 24rpx;
	}

	.myNew_fd1_1_c0_c1 {
		position: absolute;
		top: 0rpx;
		right: 0rpx;
	}

	.myNew_fd1_1_c0_c0 {
		width: 90rpx;
		height: 90rpx;
		border-radius: 45rpx 45rpx 45rpx 45rpx;
	}

	.myNew_fd1_1_c0 {
		position: relative;
	}

	.myNew_fd1_0_c1_c1 {
		font-size: 24rpx;
		font-weight: 400;
		color: rgba(153, 153, 153, 1);
		line-height: 33rpx;
		-webkit-line-clamp: 1;
		overflow: hidden;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-box-orient: vertical;
		margin: 17rpx 0rpx 0rpx 0rpx;
	}

	.myNew_fd1_0_c1_c0_c1 {
		font-size: 24rpx;
		font-weight: 400;
		color: rgba(191, 191, 191, 1);
		line-height: 33rpx;
		text-align: right;

	}

	.myNew_fd1_0_c1_c0_c0 {
		font-size: 28rpx;
		font-weight: 500;
		line-height: 40rpx;
		max-width: 450rpx;
		color: #333;
		-webkit-line-clamp: 1;
		overflow: hidden;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-box-orient: vertical;
	}

	.myNew_fd1_0_c1 {
		border-bottom: 1px solid #EEEEEE;
		padding: 32rpx 0rpx 32rpx 24rpx;
	}

	.myNew_fd1_0_c0_c1 {
		position: absolute;
		top: 0rpx;
		right: 0rpx;
	}

	.myNew_fd1_0_c0_c0 {
		width: 90rpx;
		height: 90rpx;
		border-radius: 45rpx 45rpx 45rpx 45rpx;
	}

	.myNew_fd1_0_c0 {
		position: relative;
	}
</style>